#pragma once

#include "ColligereDatabaseInterfaceBase.hpp"

namespace col {

//////////////////////////////////////////////
// ColligereFieldComboBoxClientData
//////////////////////////////////////////////

class FieldComboBoxClientData : public wxClientData
{
public:
	FieldComboBoxClientData ( const DatabaseTable &rTable,
		const DatabaseTable::Column &rColumn );

	virtual ~FieldComboBoxClientData();

	const DatabaseTable &GetTable() const;
	const DatabaseTable::Column &GetColumn() const;
private:
	const DatabaseTable &mrTable;
	const DatabaseTable::Column &mrColumn;
};

//////////////////////////////////////////////
// ColligereSearchDialog
//////////////////////////////////////////////

//! A dialog for executing searches and displaying search results.
class SearchDialog : public wxDialog
{
public:
	SearchDialog ( DatabaseInterfaceBase *pParent );
	virtual ~SearchDialog();
private:
	SearchDialog() { }

	void ConnectEventHandlers();
	
	void LoadUserPreferences();
	void SaveUserPreferences();

	////////////////////////////////
	// Event handlers
	////////////////////////////////

	void OnButtonSearch ( wxCommandEvent &rEvt );
	void OnUseRegExChecked ( wxCommandEvent &rEvt );
	void OnResultSelected ( wxListEvent &rEvt );
	void OnResultDeselected ( wxListEvent &rEvt );

	DatabaseInterfaceBase *mpParentDatabase;
	DatabaseTableDeque mCurTableList;

	typedef std::map < long, DatabaseItemBasePtr > SearchResultDataMap;
	SearchResultDataMap mSearchResultData;

//public:
	DECLARE_DYNAMIC_CLASS ( SearchDialog );
};

}